package com.kriss.favorite.biz.impl;

import java.util.List;

import com.kriss.favorite.biz.ITagBiz;
import com.kriss.favorite.common.BaseBizImpl;
import com.kriss.favorite.dao.ITagDao;
import com.kriss.favorite.entity.Tag;

public class TagBizImpl extends BaseBizImpl<Tag> implements ITagBiz {

	private ITagDao  tagDao ;

	public ITagDao getTagDao() {
		return tagDao;
	}

	public void setTagDao(ITagDao tagDao) {
		this.tagDao = tagDao;
	}

	public void dealWithTag(String tagName) {
		   try {
			List<Tag> ls = this.tagDao.findByHql("from Tag where tname = ?", tagName);
		
			Tag temp   = null;
			if(ls!=null&&ls.size()>0){
				temp = (Tag)ls.get(0);
				 
				 if(temp!=null){
					 temp.setTcount(temp.getTcount()+1);
				 }
			}else{
				temp  =new Tag();
				temp.setTcount(0);
				temp.setTname(tagName);
			}
			
			tagDao.saveOrupdate(temp);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	


}
